﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>代码生成</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiAdmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiAdmin/style/admin.css" media="all">
    <link rel="stylesheet" href="../../layuiAdmin/style/wizard.css" media="all">
    <link rel="stylesheet" href="../../layuiAdmin//style/font-awesome/css/font-awesome.min.css">
    <style>
        html {
            background-color: white !important;
        }

        #step-3 .layui-card-body {
            padding: 10px;
            overflow: auto;
            height: -webkit-calc(100vh - 170px);
            height: -moz-calc(100vh - 170px);
            height: calc(100vh - 170px);
        }

        #step-3 #form_element {
            height: -webkit-calc(100vh - 200px);
            height: -moz-calc(100vh - 200px);
            height: calc(100vh - 200px);
            overflow: auto;
        }

            #step-3 #form_element > div {
                margin-bottom: 15px;
                box-sizing: border-box;
                border-style: solid;
                border-color: white;
            }

        #step-3 .selected {
            border-color: red !important;
        }

        #step-4 .layui-form-label {
            width: 100px;
        }

        #step-4 .layui-input-block {
            margin-left: 130px;
        }

        #step-5 a {
            position: absolute;
            right: 20px;
            bottom: 60px;
        }

        #step-5 pre {
            height: 440px;
            overflow: auto;
        }

        #step-6 {
            height: 540px;
        }
        #step-6 .fa-fw {
            left: 0px;
        }
    </style>
</head>

<body>
    <div class="layui-fluid">
        <div class="layui-row">
            <div id="wizard" class="wizard" data-target="#wizard-steps">
                <ul class="steps">
                    <li data-target="#step-1" class="active">
                        <span class="step">1</span>列表页面<span class="chevron"></span>
                    </li>
                    <li data-target="#step-2"><span class="step">2</span>查询条件<span class="chevron"></span></li>
                    <li data-target="#step-3"><span class="step">3</span>表单页面<span class="chevron"></span></li>
                    <li data-target="#step-4"><span class="step">4</span>信息配置<span class="chevron"></span></li>
                    <li data-target="#step-5"><span class="step">5</span>查看代码<span class="chevron"></span></li>
                    <li data-target="#step-6"><span class="step">6</span>发布功能<span class="chevron"></span></li>
                </ul>
            </div>
            <div class="step-content" id="wizard-steps">
                <div class="step-pane active" id="step-1">
                    请勾选列表所需要显示的字段
                    <table id="field-code" lay-filter="field-code"></table>
                </div>
                <div class="step-pane" id="step-2">
                    <button type="button" class="layui-btn layui-btn-sm" id="add-sfield">新增查询字段</button>
                    <button type="button" class="layui-btn layui-btn-sm" id="delete-sfield">删 除</button>
                    <table id="search-code" lay-filter="search-code"></table>
                </div>
                <div class="step-pane" id="step-3" style="background-color:#f0f0f0;padding-left:5px;padding-right:5px;">
                    <div class="layui-row layui-col-space10">
                        <div class="layui-col-md3">
                            <div class="layui-card">
                                <div class="layui-card-header">表单元素</div>
                                <div class="layui-card-body">
                                    <div class="layui-btn-container" id="left_element">
                                        <div><span class="layui-btn layui-btn-primary layui-btn-fluid">文本框</span></div>
                                        <div><span class="layui-btn layui-btn-primary layui-btn-fluid">时间框</span></div>
                                        <div><span class="layui-btn layui-btn-primary layui-btn-fluid">下拉框</span></div>
                                        <div><span class="layui-btn layui-btn-primary layui-btn-fluid">单选框</span></div>
                                        <div><span class="layui-btn layui-btn-primary layui-btn-fluid">开 关</span></div>
                                        <div><span class="layui-btn layui-btn-primary layui-btn-fluid">复选框</span></div>
                                        <div><span class="layui-btn layui-btn-primary layui-btn-fluid">文本域</span></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-card">
                                <div class="layui-card-header">表单排版</div>
                                <div class="layui-card-body">
                                    <form class="layui-form layui-form-pane" action="" style="min-height:300px;">
                                        <div class="layui-form-item" id="form_element">
                                            <div class="layui-col-md6 xxx">
                                                <label class="layui-form-label">显示值：</label>
                                                <div class="layui-input-block">
                                                    <input type="text" name="" placeholder="文本框" disabled
                                                           class="layui-input">
                                                </div>
                                            </div>
                                            <div class="layui-col-md6 xxx">
                                                <label class="layui-form-label">显示值：</label>
                                                <div class="layui-input-block">
                                                    <input type="text" name="" placeholder="文本框" disabled
                                                           class="layui-input">
                                                </div>
                                            </div>
                                            <div class="layui-col-md6 xxx">
                                                <label class="layui-form-label">显示值：</label>
                                                <div class="layui-input-block">
                                                    <input type="text" name="" placeholder="文本框" disabled
                                                           class="layui-input">
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-card">
                                <div class="layui-card-header">表单数据</div>
                                <div class="layui-card-body">
                                    <div class="layui-form layui-form-pane" action="" lay-filter="code-form">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">数据字段：</label>
                                            <div class="layui-input-block">
                                                <select name="cfield" lay-verify="required" lay-search></select>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">显示值：</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="lablename" lay-verify="required"
                                                       class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">默认值：</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="defaultvalue" placeholder="" autocomplete="off"
                                                       class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">行宽度</label>
                                            <div class="layui-input-block">
                                                <select name="c_width" lay-verify="required"
                                                        lay-filter="c_width-filter">
                                                    <option value="layui-col-md12">整行</option>
                                                    <option value="layui-col-md6">1/2行</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <button class="layui-btn" lay-submit lay-filter="code-form-save">
                                                保
                                                存
                                            </button>
                                            <button class="layui-btn layui-btn-danger" id="code-form-remove">
                                                移
                                                除
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="step-pane" id="step-4">
                    <div class="layui-form" lay-filter="outputSet">
                        <div class="layui-card">
                            <div class="layui-card-header">功能信息配置</div>
                            <div class="layui-card-body layui-row layui-col-space10">
                                <div class="layui-col-md6">
                                    <label class="layui-form-label">创建人员</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="createdBy" disabled placeholder="创建人员"
                                               lay-verify="required" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <label class="layui-form-label">输出区域</label>
                                    <div class="layui-input-block">
                                        <select name="outputArea" lay-verify="required">
                                            <option value="XinLife">XinLife</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <label class="layui-form-label"><span style="color:red">*</span> 功能名称</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="description" placeholder="功能名称" lay-verify="required"
                                               autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <label class="layui-form-label">模板类型</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="className" placeholder="模板类型"  value="模板类型1"
                                               autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-card">
                            <div class="layui-card-header">输出目录</div>
                            <div class="layui-card-body layui-row layui-col-space10">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">实体类输出目录</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="modelOutputDir" disabled
                                               value="XinLife.Model\T4" lay-verify="required"
                                               class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">控制器输出目录</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="controllerOutputDir" disabled
                                               value="XinLife\Controllers\T4" lay-verify="required"
                                               class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">接口类输出目录</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="interfaceOutputDir" disabled
                                               value="XinLife.Application\T4" lay-verify="required"
                                               class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">实现类输出目录</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="implementOutputDir" disabled
                                               value="XinLife.Application\T4" lay-verify="required"
                                               class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">前端项输出目录</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="htmlOutputDir" disabled
                                               value="XinLife\wwwroot\T4" lay-verify="required"
                                               autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item layui-hide">
                                    <button class="layui-btn" id="outputSet-submit" type="button" lay-submit>
                                        立即提交
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="step-pane" id="step-5">
                    <div class="layui-tab">
                        <ul class="layui-tab-title">
                            <li class="layui-this">实体类</li>
                            <li>控制器</li>
                            <li>业务接口类</li>
                            <li>业务类</li>
                            <li>列表html页</li>
                            <li>表单页</li>
                        </ul>
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <pre class="layui-code" lay-height="480px" style="top: -20px;">内容1</pre>
                            </div>
                            <div class="layui-tab-item">
                                <pre class="layui-code" lay-height="480px" style="top: -20px;">内容2</pre>
                            </div>
                            <div class="layui-tab-item">
                                <pre class="layui-code" lay-height="480px" style="top: -20px;">内容3</pre>
                            </div>
                            <div class="layui-tab-item">
                                <pre class="layui-code" lay-height="480px" style="top: -20px;">内容4</pre>
                            </div>
                            <div class="layui-tab-item">
                                <pre class="layui-code" lay-height="480px" style="top: -20px;">内容5</pre>
                            </div>
                            <div class="layui-tab-item">
                                <pre class="layui-code" lay-height="480px" style="top: -20px;">内容6</pre>
                            </div>
                            <a href="javascript:;" class="layui-btn layui-btn-normal" id="copyCode">复制代码</a>
                        </div>
                    </div>
                </div>
                <div class="step-pane" id="step-6">
                    <div class="layui-form" style="padding: 20px 10px 0 10px;">
                        <div class="layui-form-item layui-col-space10">
                            <div class="layui-col-xs6">
                                <label class="layui-form-label">菜单名称</label>
                                <div class="layui-input-block">
                                    <input type="text" name="cTitle" lay-verify="required" placeholder="请输入菜单名称"
                                           autocomplete="new-password" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-col-xs6">
                                <label class="layui-form-label">编号</label>
                                <div class="layui-input-block">
                                    <input type="text" name="cCode" placeholder="请输入编号" autocomplete="new-password"
                                           class="layui-input">
                                </div>
                            </div>
                            <div class="layui-col-xs6">
                                <label class="layui-form-label">上级</label>
                                <div class="layui-input-block" id="parentId">
                                </div>
                            </div>
                            <div class="layui-col-xs6">
                                <label class="layui-form-label">图标</label>
                                <div class="layui-input-inline" style="max-width: 30px; padding-top: 5px;" id="iconShow">
                                </div>
                                <div class="layui-input-inline" style="width:calc(100% - 160px);margin-right:auto;float:right">
                                    <input type="text" name="cIcon" lay-verify="required"
                                           autocomplete="new-password" placeholder="请双击选择图标" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-col-xs6">
                                <label class="layui-form-label">目标</label>
                                <div class="layui-input-block">
                                    <select name="cIsMenu">
                                        <option value="1">iframe</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-col-xs6">
                                <label class="layui-form-label">排序</label>
                                <div class="layui-input-block">
                                    <input type="text" name="cSortCode" lay-verify="required|number"
                                           autocomplete="new-password" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-col-xs12">
                                <label class="layui-form-label">地址</label>
                                <div class="layui-input-inline" style="width: calc(100% - 240px)">
                                    <div id="cPath"></div>
                                </div>
                                <div class="layui-input-inline" style="width: 110px; margin-right: auto; float: right ">
                                    <button class="layui-btn" id="cus_path" type="button">自定义路径 </button>
                                </div>
                            </div>
                            <div class="layui-col-xs6">
                                <label class="layui-form-label">功能按钮</label>
                                <div class="layui-input-block" id="func">
                                    <input type="checkbox" value="x-add" title="新增">
                                    <input type="checkbox" value="x-edit" title="编辑">
                                    <input type="checkbox" value="x-delete" title="删除">
                                    <input type="checkbox" value="x-batch-delete" title="批量删除">
                                </div>
                            </div>
                            <div class="layui-col-xs12">
                                <label class="layui-form-label">描述</label>
                                <div class="layui-input-block">
                                    <textarea name="cDescription" placeholder="请输入内容"
                                              class="layui-textarea"></textarea>
                                </div>
                            </div>
                            <div class="layui-hide">
                                <button class="layui-btn" id="module-submit" lay-filter="module-submit" type="button"
                                        lay-submit>
                                    立即提交
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="wz-form-bottom-button" id="wizard-actions">
            <a id="btn_prev" class="layui-btn layui-btn-primary layui-btn-sm btn-prev layui-btn-disabled">上一步</a>
            <a id="btn_next" class="layui-btn layui-btn-primary layui-btn-sm btn-next">下一步</a>
            <a id="btn_finish" class="layui-btn layui-btn-sm layui-btn-disabled">完成</a>
        </div>
    </div>
    </div>
    <script src="../../layuiAdmin/lib/extend/sortable.min.js"></script>
    <script src="../../layuiAdmin/layui/layui.js"></script>
    <script src="../../layuiAdmin/lib/extend/xm-select.js"></script>

    <script>
        layui.config({
            base: '../../layuiAdmin/', //静态资源所在路径
            version: top.layui.setter.version
        }).extend({
            index: 'lib/index', //主入口模块
        }).use(['index', 'form', 'table', 'wizard', 'code'], function () {
            var $ = layui.$,
                form = layui.form,
                admin = layui.admin,
                table = layui.table,
                element = layui.element;
            element.render();
            var tableName = $.getParam("tableName");
            //step1
            admin.req({
                type: 'get',
                url: '/api/Code/GetTableFiled?tableName=' + tableName,
                success: function (r) {
                    if (r.code == 200) {
                        table.render({
                            elem: '#field-code',
                            data: r.data,
                            height: 521,
                            page: false,
                            cols: [
                                [
                                    { type: 'checkbox', fixed: 'left' },
                                    { field: 'number', title: '序号', width: 100, align: 'center', type: 'numbers' },
                                    { field: 'column', title: '列名', minWidth: 80, align: 'center' },
                                    { field: 'remark', title: '说明', align: 'center' },
                                    { field: 'datatype', title: '数据类型', minWidth: 80 },
                                    { field: 'length', title: '长度', minWidth: 80, align: 'center' },
                                    { field: 'isnullable', title: '允许空', align: 'center' },
                                    { field: 'identity', title: '标识', align: 'center' },
                                    { field: 'key', title: '主键', align: 'center' },
                                    { field: 'default', title: '默认值', align: 'center' },
                                ]
                            ]
                        });
                    }
                }
            });

            //step2
            var searchData = [];
            table.render({
                elem: '#search-code',
                data: searchData,
                height: 521,
                page: false,
                cols: [
                    [
                        { field: 'number', title: '序号', width: 100, align: 'center', type: 'numbers' },
                        { field: 'lablename', title: '搜索框标题', width: 200 },
                        { field: 'field', title: '字段', width: 200 },
                        { field: 'width', title: '宽度', width: 200 },
                        { field: 'sortCode', title: '排序', width: 200 }
                    ]
                ]
            });
            var selectRow = null;
            table.on('row(search-code)', function (obj) {
                selectRow = obj.data;
                obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
            });
            $("#step-2 #add-sfield").on('click', function () {
                layer.open({
                    type: 2,
                    title: '查询条件',
                    content: 'addfieldForm.html?tableName=' + tableName,
                    area: ['700px', '470px'],
                    btn: ['确定', '取消'],
                    success: () => $(':focus').blur(),
                    yes: function (index, layero) {
                        var that = this.yes.arguments[1];
                        that.find('a.layui-layer-btn0').css("pointer-events", "none");
                        setTimeout(() => {
                            that.find('a.layui-layer-btn0').css("pointer-events", "")
                        }, 2000);
                        var iframeWindow = window['layui-layer-iframe' + index];
                        //监听提交
                        iframeWindow.layui.form.on('submit(form-submit)', function (data) {
                            var field = data.field; //获取提交的字段
                            layer.msg('添加成功!', { icon: 1, time: 500 }, function () {
                                layer.close(index);
                                searchData.push(field);
                                searchData = searchData.sort((a, b) => a.sortCode > b.sortCode ? 1 : -1);
                                table.reload('search-code', { data: searchData });
                            });
                        });
                        layero.find('iframe').contents().find('#form-submit').trigger('click');
                    }
                });
            });
            $("#step-2 #delete-sfield").on('click', function () {
                if (selectRow === null) {
                    return layer.msg('请选择数据');
                }
                layer.msg('删除成功!', { icon: 1, time: 500 }, function () {
                    searchData = searchData.filter(t => t.field !== selectRow.field).sort((a, b) => a.sortCode > b.sortCode ? 1 : -1);
                    table.reload('search-code', { data: searchData });
                });
            })

            //step3
            $("select[name='cfield']").SetSelect({
                url: '/api/Code/GetTableFiled?tableName=' + tableName,
                id: 'column',
                text: 'remark',
                async: false,
                success: function (r) {
                    form.render('select');
                }
            });
            var field_data = [];
            var leftElement = document.getElementById('left_element');
            var formContent = document.getElementById('form_element');
            //中间选中
            $('#form_element').on('click', '.xxx', function () {
                $(this).addClass('selected').siblings().removeClass('selected');
                var data = field_data.filter(t => t.cfield == $(this).find('input').attr('name'));
                if (data.length > 0) {
                    form.val("code-form", data[0]);
                } else {
                    form.val("code-form", {
                        "c_width": "",
                        "lablename": "",
                        "cfield": "",
                        "defaultvalue": ""
                    });
                    form.val("code-form", {
                        "c_width": $(this).attr("class").split(' ').filter(t => t.indexOf('layui-col-md') > -1)[0]
                    });
                }
                form.render('select');
            });
            //右边选择宽度时
            form.on('select(c_width-filter)', function (data) {
                var oldCss = $('.xxx.selected').attr("class").split(' ').filter(t => t.indexOf('layui-col-md') > -1)[0];
                $('.xxx.selected').removeClass(oldCss).addClass(data.value);
            });
            //保存
            form.on('submit(code-form-save)', function (data) {
                var field = data.field;
                field_data = field_data.filter(t => t.cfield != field.cfield);
                var selected = $('.xxx.selected');
                selected.find('label').html(field.lablename);
                selected.find('input').attr('name', field.cfield);
                form.render('select');
                field_data.push(field);
                parent.layer.msg('保存成功!')
            });
            //移除
            $('#code-form-remove').on('click', function () {
                var selected = $('.xxx.selected');
                field_data = field_data.filter(t => t.cfield != selected.find('input').attr('name'));
                form.val("code-form", {
                    "c_width": "",
                    "lablename": "",
                    "cfield": "",
                    "defaultvalue": ""
                });
                selected.remove();
                parent.layer.msg('移除成功!')
            });

            new Sortable(leftElement, {
                group: {
                    name: 'shared',
                    pull: 'clone' // To clone: set pull to 'clone'
                },
                animation: 150
            });

            new Sortable(formContent, {
                group: {
                    name: 'shared',
                    pull: 'false'
                },
                animation: 150,
                onAdd: function ( /**Event*/ evt) {
                    if (evt.item.innerText == "时间框") {

                    } else if (evt.item.innerText == "下拉框") {

                    } else if (evt.item.innerText == "单选框") {

                    }
                    $(evt.item).addClass('layui-col-md6 xxx');
                    var html = [];
                    html.push('<label class="layui-form-label">显示值：</label>');
                    html.push(' <div class="layui-input-block">');
                    html.push('<input type="text" name="" placeholder="' + evt.item.innerText + '" disabled class="layui-input">');
                    html.push('</div>');
                    $(evt.item).html(html.join(''));
                },
            })
            //step4
            $("#step4,input[name='createdBy']").val(layui.sessionData(layui.setter.tableName)["UserInfo"].user.cUserName);
            //step5
            layui.code({ elem: 'pre', skin: 'notepad' });
            $("#copyCode").on('click', function () {
                var index = $("#step-5 .layui-this").index();
                let textareaEl = document.createElement('textarea')
                textareaEl.value = $("#step-5 pre")[index].innerText;
                document.body.appendChild(textareaEl);
                textareaEl.select();
                document.execCommand('copy');
                document.body.removeChild(textareaEl);
                layui.layer.msg("复制成功");
            });
            //step6
            xmSelect.render({
                el: '#parentId',
                name: 'cParentId',
                tips: '请选择父级菜单',
                model: { label: { type: 'text' } },
                radio: true,
                clickClose: true,
                tree: {
                    show: true,
                    strict: false,
                    expandedKeys: [],
                },
                height: 'auto',
                data() {
                    var data = null;
                    admin.req({
                        type: 'get',
                        async: false,
                        url: '/api/Module/GetParentIdModule',
                        success: function (r) {
                            if (r.code == 200) {
                                data = r.data;
                            }
                        }
                    });
                    return data;
                }
            })

            var xmPaths = xmSelect.render({
                el: '#cPath',
                name: 'cPath',
                tips: '请选择页面路径',
                model: { label: { type: 'text' } },
                radio: true,
                clickClose: true,
                direction: 'down',
                tree: {
                    show: true,  //是否显示树状结构
                    showFolderIcon: true, //是否展示三角图标
                    showLine: true, //是否显示虚线
                    indent: 20, //间距
                    strict: false, //是否严格遵守父子模式
                    clickCheck: true,//点击节点是否选中
                },
                height: '150px',
                filterable: true,
                data() {
                    var data = null;
                    admin.req({
                        type: 'get',
                        async: false,
                        url: '/api/Module/GetPageDir',
                        success: function (r) {
                            if (r.code == 200) {
                                data = r.data;
                            }
                        }
                    });
                    return data;
                }
            });

            $("input[name='cIcon']").on('dblclick', function () {
                parent.layer.open({
                    type: 2,
                    title: '图标',
                    area: ['800px', '500px'], //宽高
                    content: '../home/icon1.html',
                    success: function (layero, index) {
                        var li = layero.find('iframe').contents().find('li');
                        li.on('dblclick', function () {
                            let icon_text = $(this).find('.doc-icon-fontclass').text();
                            $("input[name='cIcon']").val(icon_text);
                            parent.layer.close(index);
                            $("#iconShow").html('<i class="layui-icon ' + icon_text + '" style="font-size:30px"></i>');
                        })
                        var a = layero.find('iframe').contents().find('#icons a');
                        a.on('dblclick', function () {
                            let icon_text = $(this).find('i').attr("class").replace("fa ", "");
                            $("input[name='cIcon']").val(icon_text);
                            $("#iconShow").html(' <i class="fa ' + icon_text + ' fa-fw fa-2x" aria-hidden="true"></i>');
                            parent.layer.close(index);
                        })
                    }
                });
            });

            $("#cus_path").click(function () {
                layer.prompt({ title: '自定义页面地址', formType: 2, area: ['520px', '25px'] }, function (text, index) {
                    layer.close(index);
                    xmPaths.setValue([{ name: text, value: text }]);
                });
            })

            //提交保存
            form.on('submit(module-submit)', function (data) {
                var field = data.field; //获取提交的字段
                if (field.cParentId == "") field.cParentId = 0;
                //提交
                var data = { tableName: tableName };
                data.listfield = table.checkStatus('field-code').data;
                data.searchFields = searchData;
                data.formFields = field_data;
                data.setInfo = form.val("outputSet");
                data.moduleInfo = field;

                var buttons = [];
                $("#func").find('input[type="checkbox"]:checked').each(function (index, item) {
                    buttons.push(item.value);
                })
                data.moduleInfo.buttons = buttons;
                admin.req({
                    type: 'post',
                    url: "/api/Code/SaveMenu",
                    data: data,
                    success: function (data) {
                        if (data.code == 200) {
                            parent.layer.msg('操作成功!', { icon: 1, time: 1000 }, function () {
                                parent.layui.table.reload('dataItem-manage');
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                            });
                        } else {
                            layer.msg('操作失败!\n' + data.msg, { icon: 2, time: 1000 });
                        }
                    }
                });
            });
            // 加载导向
            $('#wizard').wizard().on('change', function (e, data) {
                var $finish = $("#btn_finish");
                var $next = $("#btn_next");
                if (data.direction == "next") {
                    if (data.step == 1) {
                        var checkStatus = table.checkStatus('field-code'),
                            checkData = checkStatus.data; //得到选中的数据
                        if (checkData.length === 0) {
                            layer.msg('请选择数据');
                            return false;
                        }
                    }
                    else if (data.step == 2) { }
                    else if (data.step == 3) { }
                    else if (data.step == 4) {
                        $("#outputSet-submit").click();
                        var opSetData = form.val("outputSet");
                        if (opSetData.className == "" || opSetData.description == "" || opSetData.outputArea == "") {
                            return false;
                        }
                        var data = { tableName: tableName };
                        data.listfield = table.checkStatus('field-code').data;
                        data.searchFields = searchData;
                        data.formFields = field_data;
                        data.setInfo = form.val("outputSet");
                        admin.req({
                            type: 'post',
                            async: false,
                            url: "/api/Code/CodeGenerate",
                            data: data,
                            success: function (res) {
                                if (res.code == 200) {
                                    $("#step-5 pre")[0].innerText = res.data.modelText;
                                    $("#step-5 pre")[1].innerText = res.data.controllerText;
                                    $("#step-5 pre")[2].innerText = res.data.interfaceText;
                                    $("#step-5 pre")[3].innerText = res.data.implementText;
                                    $("#step-5 pre")[4].innerText = res.data.webText;
                                    $("#step-5 pre")[5].innerText = res.data.formText;
                                } else {
                                    layer.msg('操作失败!\n' + data.msg, { icon: 2, time: 1000 });
                                }
                            }
                        });
                    }
                    else if (data.step == 5) {
                        $finish.removeClass('layui-btn-disabled');
                        $next.addClass('layui-btn-disabled');
                    }
                    else {
                        $finish.addClass('layui-btn-disabled');
                    }
                } else {
                    $finish.addClass('layui-btn-disabled');
                    $next.removeClass('layui-btn-disabled');
                }
            });
            $("#btn_finish").on('click', function () {
                $("#module-submit").click();
            })
        });
    </script>
</body>

</html>